import request from "request"
import cheerio  from "cheerio";
import jsdom from 'jsdom'
const getCrowerData = (url)=>{
    url = url || targetApi
    var options = {
        'method': 'get',
        'url': encodeURI(url)
      }
      return new Promise((resolve,roject)=>{
        request(options, function (error, response, body) {
            // 如果请求成功且状态码为 200
            if (error){
                console.log(error)
                resolve(error)
                return
            }
            const { JSDOM } = jsdom;
            console.log(response.body)
            const template =new JSDOM(response.body);
            console.log(template.window)
            const $ = cheerio.load(template.window.document);
            // const dom = new JSDOM($);
            resolve($ )
          });
      })

}
export default getCrowerData